package collections.list.array_list;

import static org.hamcrest.CoreMatchers.equalTo;

import java.util.Iterator;
import java.util.NoSuchElementException;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class MyArrayListTestsEmpty {

	MyArrayList<Integer> list;

	@Before
	public void initCollection() {
		list = new MyArrayList<>();
	}

	@Test
	public void should_change_size_after_adding_new_element() {
		Assert.assertThat(list.size(), equalTo(0));
		list.add(0);
		Assert.assertThat(list.size(), equalTo(1));
	}

	@Test
	public void iterator_should_not_throw_any_exception() {
		Iterator<Integer> iterator = list.iterator();
		Assert.assertThat(iterator.hasNext(), equalTo(false));
	}

	@Test(expected = NoSuchElementException.class)
	public void indexOf_method_should_throw_NoSuchElementException_exception() {
		list.indexOf(0);
	}
}
